package cm.wc;

import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

/**
 * @ClassName:jdbcupdate
 * @Author: 鹿建文
 * @Date: 2022/3/30  - 10:18
 * @Describe:
 */
public class jdbcupdate {
    private static String url;
    private static String user;
    private static String password;

    static {
        Properties properties = new Properties();
        try {
            properties.load(new FileReader("src/main/resources/mysql.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        url = properties.getProperty("url");
        user = properties.getProperty("user");
        password = properties.getProperty("password");
    }


    public static void main(String[] args) throws SQLException {
        Connection conn = DriverManager.getConnection(url, user, password);
        Statement stmt = conn.createStatement();

        String s = "UPDATE tbtest set name='aaa' ,author='bb' ,birth ='1999-8-16' WHERE id=23";
        int i = stmt.executeUpdate(s);
        System.out.println(i);

        try {
            if (stmt!=null){
                stmt.close();
            }

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {

            try {
                if (conn!=null){
                    conn.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
